namespace SimpleWebServices.Configuration
{
    using System.Globalization;
    using System.Text;
    using System.Xml.Serialization;
    using SimpleWebServices.Web;

    [XmlRoot("analytics")]
    public sealed class AnalyticsSettings
    {
        [XmlAttribute("enabled")]
        public bool Enabled
        {
            get;
            set;
        }

        [XmlElement("google")]
        public GoogleAnalytics Google
        {
            get;
            set;
        }

        public string Render()
        {
            StringBuilder buffer = new StringBuilder();

            buffer.AppendFormat(CultureInfo.InvariantCulture, "<div id='analytics' class='{0}'>", this.Enabled ? "enabled" : "disabled");

            if (this.Enabled)
            {
                buffer.Append(this.Google);
            }

            buffer.Append("</div>");

            return buffer.ToString();
        }
    }
}